** This code reproduces the appendix results for Study 1 (Tables A3, A4, A5, and A7)


* ------------- *
* 	TABLE A3	*
* ------------- *

* Opens data
use "$directory/European Social Survey 6 and 10 DiD/data/ESS_final.dta", clear

* Manipulation check 1: DiD on preferring "many" people from different race or ethnic group coming to live in the country (Table A3)
eststo clear 
eststo m1: logit allowmanydif i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp i.country i.essround  if repeat==1 [pweight=anweight],  cluster (country)
margins, dydx(selfcompletion) 

* Manipulation check 2: DiD on preferring "many" people from different race or ethnic group coming to live in the country, with excessdeath (Table A3) 
eststo m2: logit allowmanydif i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp i.country i.essround excessdeath  if repeat==1 [pweight=anweight],  cluster (country)
margins, dydx(selfcompletion) 

* Exports table (in .tex format)
esttab m2 m1 ///
   using "$directory/Output/Table_A3.tex" ///
   , obslast gaps ar2 nonumbers nonotes se ///
   drop(0.selfcompletion 1.gndr 1.eisced 1.hincfel 3.country 4.country 5.country 6.country 7.country 8.country 10.country 11.country 12.country 13.country 14.country 17.country 18.country 19.country 20.country 21.country 22.country 26.country 27.country 28.country 29.country 32.country 33.country 34.country 6.essround 10.essround) ///
   addnotes("\textit{Note:} Logistic regression estimates with country and ess round fixed effects (TWFE)." "Cluster robust tandard errors are in parentheses (cluster on country)." ///
		"\sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\) (two-sided tests).") ///
   title("Self-Completion Reduces Expression of Pro-Immigration Attitudes") ///
   varlabels(1.selfcompletion "Treatment Group" 2.gndr "Female" agea "Age" c.agea#c.agea "Age (squared)" 2.eisced "Lower secondary" 3.eisced "Lower tier, upper secondary" ///
		4.eisced "Upper tier, upper secondary" 5.eisced "Advanced vocational" 6.eisced "Lower tertiary" 7.eisced "Higher tertiary" 55.eisced "Other" ///
		2.hincfel "Coping on present income" 3.hincfel "Difficult on present income" 4.hincfel "Very difficult on present income" GDPpc1 "GDP per cap." contcorrupt "Control of corruption" ginidisp "Gini" ///
		_cons Constant excessdeath "Covid-19 Excess Death") ///
   mti("Pro-Immigration Attitude" "Pro-Immigration Attitude") ///
   replace b(%7.2f) se(%7.2f)


* ------------- *
* 	TABLE A4	*
* ------------- *

* Opens data   
use "$directory/European Social Survey 6 and 10 DiD/data/ESS_rounds6-9.dta", clear

* Estimates effect of self-complete (round 10) on changes in levels of SWD: 
eststo clear
eststo m1: reghdfe stfdem i.selfcompl10 i.gndr c.agea##c.agea i.eisced i.hincfel gdppc contcorr gini  [pweight=anweight], absorb (country essround) cluster (country)

* Exports table (in .tex format)
esttab m1 using ///
		"$directory/Output/Table_A4.tex" ///
		, obslast gaps ar2 nonumbers nonotes se ///
		drop(0.selfcompl10 1.gndr 1.eisced 1.hincfel) ///
		addnotes("\textit{Note:} Unstandardized OLS regression estimates with country and ess round fixed effects (TWFE)." "Cluster robust tandard errors are in parentheses (cluster on country)." ///
		"\sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\) (two-sided tests).") ///
		title("Common Trends: Generalized DiD (OLS) for SWD between rounds 6 and 9") ///
		varlabels(1.selfcompl10 "Treatment Group" 2.gndr "Female" agea "Age" c.agea#c.agea "Age (squared)" 2.eisced "Lower secondary" 3.eisced "Lower tier, upper secondary" ///
		4.eisced "Upper tier, upper secondary" 5.eisced "Advanced vocational" 6.eisced "Lower tertiary" 7.eisced "Higher tertiary" 55.eisced "Other" ///
		2.hincfel "Coping on present income" 3.hincfel "Difficult on present income" 4.hincfel "Very difficult on present income" gdppc "GDP per cap." contcorr "Control of corruption" gini "Gini" ///
		_cons Constant) ///
		mti("Satisfaction with Democracy (SWD)") ///
		replace b(%7.2f) se(%7.2f) 


* ------------- *
* 	TABLE A5	*
* ------------- *

* Opens data   
use "$directory/European Social Survey 6 and 10 DiD/data/ESS_final.dta", clear

* Estimates coefficients for Table A5
eststo clear
eststo m1: reghdfe stfdem i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
eststo m2: reghdfe implvdm i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
eststo m3: reghdfe fairelc i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
eststo m4: reghdfe dfprtal i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
eststo m5: reghdfe gptpelc i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
eststo m6: reghdfe medcrgv  i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
eststo m7: reghdfe cttresa  i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
eststo m8: reghdfe rghmgpr  i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)

* Exports table (in .tex format)
esttab m1 m2 m3 m4 m5 m6 m7 m8 using ///
		"$directory/Output/Table_A5.tex" ///
		, obslast gaps ar2 nonumbers nonotes se ///
		drop(0.selfcompletion 1.gndr 1.eisced 1.hincfel) ///
		addnotes("\textit{Note:} Unstandardized OLS regression estimates with country and ess round fixed effects (TWFE)." "Cluster robust tandard errors are in parentheses (cluster on country)." ///
		"\sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\) (two-sided tests).") ///
		title("Effect of Survey Mode on Expressed Democratic Attitudes") ///
		varlabels(1.selfcompletion "Treatment" 2.gndr "Female" agea "Age" c.agea#c.agea "Age$^2$" 2.eisced "Lower second." 3.eisced "Lower tier, upper second." ///
		4.eisced "Upper tier, upper second." 5.eisced "Advanced vocational" 6.eisced "Lower tertiary" 7.eisced "Higher tertiary" 55.eisced "Other" ///
		2.hincfel "Coping on income" 3.hincfel "Diff. on income" 4.hincfel "V. diff. on income" gdppc "GDP per cap." contcorr "Control of corruption" gini "Gini" ///
		_cons Constant) ///
		mti("SWD" "Importance Democracy" "Fair Elections" "Partisan Alternatives" "Punish Govt." "Media Free" "Impartial Courts" "Minority Rights") ///
		replace b(%7.2f) se(%7.2f) 


		
* ------------- *
* 	TABLE A7	*
* ------------- *

** Note that Table A7 was created manually. Point estimates and standard errors obtained from regressions in Step 1 (coefficient for variable "i.selfcompletion"). P-values optained from Step 2. 

* Opens data   
use "$directory/European Social Survey 6 and 10 DiD/data/ESS_final.dta", clear

* Step 1: Estimates point estimates and standard errors Table A7
reghdfe stfdem i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp excessdeath if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
reghdfe implvdm i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp excessdeath if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
reghdfe fairelc i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp excessdeath if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
reghdfe dfprtal i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp excessdeath if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
reghdfe gptpelc i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp excessdeath if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
reghdfe medcrgv  i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp excessdeath if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
reghdfe cttresa  i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp excessdeath if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)
reghdfe rghmgpr  i.selfcompletion i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp excessdeath if repeat==1 [pweight=anweight], absorb (country essround) cluster (country)

* Step 2: Estimating Romano-Wolf adjusted p-values for Table A7
rwolf stfdem implvdm fairelc dfprtal gptpelc medcrgv cttresa rghmgpr [pweight=anweight] if repeat==1, indepvar(selfcompletion) controls(i.gndr c.agea##c.agea i.eisced i.hincfel GDPpc1 contcorrupt ginidisp i.essround excessdeath) reps(250) method(areg) abs(country) cluster (country) vce(cluster country) seed(1111)



